If you use the original World Template, it will create a small amount of global code for your game. However, it is not even close to the amount of code you will need to correctly provide for all the standard commands in a quality adventure game.
To remedy this, I have added my own custom global code to "Ray's World Template." To use the template, just make a duplicate of it. Change the name of the duplicate to whatever you want your game to be called. For additional instructions, be sure to read the file called "Getting Started."
The global code I've written into the template will be included in your game. You will need most of it, if you want your game to respond properly when the player enters common commands. Some of it you may not need, depending on your game. You can remove or alter any of it that you don't need. Some of the code keeps track of the player's money, some of it handles eating food or drinking from a canteen. These things will require additional scene code to complete the process. I will describe the necessary code further on in this text.
Here is the complete global code that you will find, followed by a detailed explanation of each segment:
IF{TEXT$=MOVE}OR{TEXT$=PUSH}OR{TEXT$=PULL}THEN
PRINT{You can't move that.}
EXIT
IF{TEXT$=SEARCH}THEN
PRINT{You find nothing unusual.}
EXIT
IF{TEXT$=OPEN}THEN
PRINT{You can't open anything here.}
EXIT
IF{TEXT$=CLOSE}THEN
PRINT{You can't close anything here.}
EXIT
IF{TEXT$=ENTER}THEN
PRINT{You can't enter anything here.}
EXIT
IF{TEXT$=EXIT}THEN
PRINT{You can't exit anything here.}
EXIT
IF{TEXT$=UP}OR{TEXT$=CLIMB}THEN
PRINT{You can't go up here.}
EXIT
IF{TEXT$=DOWN}THEN
PRINT{You can't go down here.}
EXIT
IF{TEXT$=USE}THEN
PRINT{That doesn't work.}
EXIT
IF{TEXT$=HIT}OR{TEXT$=BREAK}THEN
PRINT{You can't break that.}
EXIT
IF{TEXT$=SHOOT}THEN
PRINT{You shouldn't shoot that.}
EXIT
IF{TEXT$=READ}THEN
PRINT{Read what?}
EXIT
IF{TEXT$=EAT}OR{TEXT$=TASTE}THEN
PRINT{..................................}
IF{TEXT$=FOOD}THEN
IF{FOOD=PLAYER@}THEN
SOUND{CHEWING.1}
SOUND{BELCH.2}
PRINT{The food is filling.}
LET{H1#=95}
MOVE{FOOD}TO{STORAGE@}
EXIT
PRINT{You don't have any food.}
EXIT
PRINT{Eat what?}
EXIT
IF{TEXT$=$}OR{TEXT$=COUNT MONEY}THEN
PRINT{..................................}
IF{CASH>PLAYER@}OR{M1#<1}THEN
PRINT{You have no CASH.}
EXIT
PRINT{You have}
PRINT{M1#}
PRINT{dollars.}
EXIT
IF{TEXT$=DRINK}THEN
PRINT{..................................}
IF{CANTEEN=PLAYER@}THEN
IF{W1#>0}THEN
LET{W1#=W1#-1}
SOUND{DROWNING.1}
PRINT{The water in the canteen relieves your thirst.}
LET{H2#=90}
IF{W1#=0}THEN
PRINT{The canteen is now empty.}
EXIT
EXIT
PRINT{Your canteen is empty.}
EXIT
PRINT{Drink what?}
EXIT
IF{TEXT$=THANKS}OR{TEXT$=THANK YOU}THEN
PRINT{"You're welcome!"}
EXIT
IF{TEXT$=TURN}OR{TEXT$=TWIST}THEN
PRINT{You can't turn that.}
EXIT
IF{TEXT$=DIG}THEN
PRINT{You can't dig here.}
EXIT
IF{TEXT$=INSPECT}OR{TEXT$=EXAMINE}THEN
PRINT{Click on the things you want to examine.}
EXIT
----------------------------------------------
This is the end of the Global code in Ray's World Template. Below is a breakdown of the code into segments, with explanations of each section:
IF{TEXT$=MOVE}OR{TEXT$=PUSH}OR{TEXT$=PULL}THEN
PRINT{You can't move that.}
EXIT
This statement will print in the text window of the current scene, a default response whenever the player tries to move, push or pull something. If there is anything in the scene that can be moved in one of these ways, it would be handled by the scene code. But if the player tries to move something that is not handled by scene code, this will ensure that the player gets an appropriate response.
IF{TEXT$=SEARCH}THEN
PRINT{You find nothing of interest.}
EXIT
"Search" is a common command used in most World Builder games. It is included in the Commands menu during the game. This statement will print a default response whenever there is nothing to be found during a search.
IF{TEXT$=OPEN}THEN
PRINT{You can't open anything here.}
EXIT
IF{TEXT$=CLOSE}THEN
PRINT{You can't close anything here.}
EXIT
These two statements print the default response anytime the player tries to open or close something that cannot be opened or closed, except when there is specific scene code to handle it.
IF{TEXT$=ENTER}THEN
PRINT{You can't enter anything here.}
EXIT
IF{TEXT$=EXIT}THEN
PRINT{You can't exit anything here.}
EXIT
IF{TEXT$=UP}OR{TEXT$=CLIMB}THEN
PRINT{You can't go up here.}
EXIT
IF{TEXT$=DOWN}THEN
PRINT{You can't go down here.}
EXIT
These four statements are pretty self-explanatory. If the player tries to enter or exit something that isn't handled by scene code, these statements print the default response. The second pair of statements print the defaults for "up" "climb" and "down." When a player uses "climb," he or she almost always wants to go up, so the two words are treated the same here. Wherever there is something that that player is likely to try to go down by climbing, the code to handle that should be included in the scene code.
IF{TEXT$=USE}THEN
PRINT{That doesn't work.}
EXIT
The most common command verb should always be "use." Whenever the player tries to use something in the wrong place or the wrong way, this statement prints a default response. In some scenes you may need to add some more specific responses to the scene code, usually for the purpose of explaining why the requested action doesn't work.
IF{TEXT$=HIT}OR{TEXT$=BREAK}THEN
PRINT{You can't break that.}
EXIT
This one is also pretty obvious -- a default response to a couple of common commands.
IF{TEXT$=SHOOT}THEN
PRINT{You shouldn't shoot that.}
EXIT
Another default response statement. It's not really necessary to check whether or not the player has a gun, since in either case the player is going to be prevented from carrying out the action. In some scenes you may need scene code that provides more specific responces. Of course, if there are no guns in the game at all, then you could delete this entirely.
IF{TEXT$=READ}THEN
PRINT{Read what?}
EXIT
The default response here is a question that asks the player to specify what it is he wants to read. The reason for this is, if you give the player several possible things to read, such as a map, a sign, a newspaper, or a book, the only way to provide the correct action for each object is if the player is specific. Some objects like maps might be carried, and could be read in any scene. In that case, you would need to place the appropriate code here, as a nested sub-statement under "read". For signs and other stationary objects, the code can go in the scene code. Check out the code in my WB Demo game, or in A Mess O'Trouble, to see examples of how I've handled these situations.
IF{TEXT$=EAT}OR{TEXT$=TASTE}THEN
PRINT{..................................}
IF{TEXT$=FOOD}THEN
IF{FOOD=PLAYER@}THEN
SOUND{CHEWING.1}
SOUND{BELCH.2}
PRINT{The food is filling.}
LET{H1#=95}
MOVE{FOOD}TO{STORAGE@}
EXIT
PRINT{You don't have any food.}
EXIT
PRINT{Eat what?}
EXIT
This code may not be needed, if you don't plan to have require eating in your game. In that case, all you'd need is a simple statement that prints "You can't eat that."
But if you do want to make eating a part of your game, the code here will provide a good starting point. I've use variable H1 as a counter to keep track of the player's hunger. When the player eats the food, H1 is reset to 95, and the food object is moved to storage. Much more code will be needed to make a complete eat/hunger function.
First, you'd need some code near the beginning of the global code, which detects when the variable H1 goes below a certain point, say 15. This code should print a message telling the player that he needs to eat soon. Additional code will be needed that prints a message telling the player that he has died of hunger if H1 drops below zero, and moves the player character to storage to end the game.
Also, you'd need some code in each scene that reduces H1 by one point each time the player enters a scene. In this way, the player's hunger points will gradually be reduced as he moves through the game. Also, be sure to provide plenty of places where the player can obtain food in the game. You don't want to make it too difficult. The player shouldn't have to struggle constantly to avoid starvation. And some scene code will be needed if there are any places where the player can find non-portable food sources, such as restaurants or inns.
IF{TEXT$=$}OR{TEXT$=COUNT MONEY}THEN
PRINT{..................................}
IF{CASH>PLAYER@}OR{M1#<1}THEN
PRINT{You have no CASH.}
EXIT
PRINT{You have}
PRINT{M1#}
PRINT{dollars.}
EXIT
If you don't intend to use money at all in your game, you can delete this. But if you do want to use money, this code is an efficient way to tell the player how much money he has. The variable M1 is used here as a counter for the player's money. In the Objects list, you will need a CASH object, which the player must have if he has money. Whenever the player spends all his money in a store or inn, be sure to move the CASH object to storage. Instead of CASH, you could have a purse, pouch or wallet that the player can carry at all times. In either case, a variable such as M1 must always be sued to keep track of the actual amount of money.
If you use the CASH object, or a wallet, or purse, you'll also need some coins or similar object that the player can find or earn to whenever needed. This object should be moved to storage when the player picks it up. It should never be carried. When the player takes the coins and they are moved to storage, update the money variable as much as desired. All of this should be handled in the scene code.
And of course, you don't have to use dollars. You can report the player's cash amounts in the form or gold pieces, wampum, or anything else that suits you.
IF{TEXT$=DRINK}THEN
PRINT{..................................}
IF{CANTEEN=PLAYER@}THEN
IF{W1#>0}THEN
LET{W1#=W1#-1}
SOUND{DROWNING.1}
PRINT{The water in the canteen relieves your thirst.}
LET{H2#=90}
IF{W1#=0}THEN
PRINT{The canteen is now empty.}
EXIT
EXIT
PRINT{Your canteen is empty.}
EXIT
PRINT{Drink what?}
EXIT
Like the food code describe earlier, this section handles drinking. A canteen is needed to carry the player's water, and the variable W1 is used to count the number o drinks he can take before the canteen is empty. Varible H2 is used to represent the player's thirst. Like the hunger code, this is just the beginning. You will also need to provide places where the player can refill the canteen (or whatever you choose to use). And you'll need some code to handle any attempts to empty the canteen or to fill it with anything other than water.
If you decide not to have this feature in your game, you should at least have a statement that prints a default response of "You can't drink that." for those times when the player may try to consume some inappropriate substance in the game. (If the player encounters a "mucous beast" for instance, you can bet that some wiseguy or desperate player will try to defeat it by drinking it.)
IF{TEXT$=THANKS}OR{TEXT$=THANK YOU}THEN
PRINT{"You're welcome!"}
EXIT
When I started making games, I noticed during test play that some players would enter "thank you" or thanks" whenever a non-player character gave them information or useful objects. As a result, I made a point of adding a default response for this.
IF{TEXT$=TURN}OR{TEXT$=TWIST}THEN
PRINT{You can't turn that.}
EXIT
Even if you don't have anything that the player can turn in your game, you still need this default response, because inevitably someone will try to turn or twist something.
IF{TEXT$=DIG}THEN
PRINT{You can't dig here.}
EXIT
This one's pretty obvious. Remember, the point of these default responses is to provide a reasonable response to actions that a player might try, whether or not there is anyplace in the game where that action is required.
IF{TEXT$=INSPECT}OR{TEXT$=EXAMINE}THEN
PRINT{Click on the things you want to examine.}
EXIT
This one tells the player how to get a description of objects in the scene, if the player tries to "inspect" or "examine" them. In many text adventures, inspect and examine are the verbs used to get object descriptions, and players who are used to that may try it in a graphic adventure.
These are some of things that should be in almost any game. Your own game may very well need additional default response, and other special code actions in the global code. Remember that there is a limit of 10,240 text characters allowed in the global code, so be careful about what goes into your global code.